
%To be called by newton(@f3, @df3, guess) to find lambda0 as given on p. 494 [W,C]
%This will give problems if guess is to the right of the zero.  
%guess should be set to -2*gammaMin(p0) + eps

function output = f0(lambda)

p0 = -2;
m = 100;
g = 9.8;

h = abs(p0)/m;

q = 0;
intGamma = 0;
for i = 1:m-1
	intGamma = intGamma - (feval(@gamma, (i-1)*h)+feval(@gamma, i*h))*h*0.5;
	q = q - 0.5*h*(lambda + 2*intGamma)^(-1.5);
	next = intGamma - (feval(@gamma, (i)*h)+feval(@gamma, (i+1)*h))*h*0.5;
	q = q - 0.5*h*(lambda + 2*next)^(-1.5);
end
i = m;
intGamma = intGamma - (feval(@gamma, (i-1)*h)+feval(@gamma, i*h))*h*0.5
q = q - h*(lambda + 2*intGamma)^(-1.5)

output = g*q + 1.0;

end

